﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using YAPL.Language.Compiler.CodeGen.ReflectionEmitGenerator.AstGen.Helpers;


namespace YAPL.Language.Compiler.CodeGen.ReflectionEmitGenerator.AstGen {
	public class ReClassDefGenerator : ReExpressionGenerator {
		public ReClassDefGenerator(ReCodeGenerator generator) : base(generator) {}
		public override void Generate(Ast.Expression expr) {
			var classDefExpr = (Ast.ClassDefExpression)expr;
			var ilGen = Generator.Get<ILGenerator>(ReCodeGenerator.IL_GENERATOR_KEY);

			ilGen.EmitDefineClass(classDefExpr.ClassName);

			Generator.EnterScope(classDefExpr.ClassName);
			Generator.EmitExpression(classDefExpr.ClassBody);
			Generator.LeaveScope(classDefExpr.ClassName);
		}
	}
}
